package material.command.remote;

import material.command.receiver_命令接收者.CeilingFan;
import material.command.receiver_命令接收者.GarageDoor;
import material.command.receiver_命令接收者.Light;
import material.command.receiver_命令接收者.Stereo;
import material.command.simpleRemote.GarageDoorOpenCommand;
import material.command.simpleRemote.LightOnCommand;

public class RemoteLoader {
    public static void main(String[] args) {
        /*声明遥控对象*/
        Light livingRoomLight = new Light("卧室");
        Light kitchenLight = new Light("厨房");
        CeilingFan ceilingFan = new CeilingFan("卧室");
        GarageDoor garageDoor = new GarageDoor("");
        Stereo stereo = new Stereo("客厅");
        /*创建电灯指令对象*/
        LightOnCommand livingRoomLightOn = new LightOnCommand(livingRoomLight);
        LightOffCommand livingRoomLightOff = new LightOffCommand(livingRoomLight);
        LightOnCommand kitchenLightOn = new LightOnCommand(kitchenLight);
        LightOffCommand kitchenLightOff = new LightOffCommand(kitchenLight);
        /*创建吊扇的开与关指令*/
        CeilingFanOnCommand ceilingFanOn = new CeilingFanOnCommand(ceilingFan);
        CeilingFanOffCommand ceilingFanOff = new CeilingFanOffCommand(ceilingFan);
        /*创建车库的开与关指令*/
        GarageDoorOpenCommand garageDoorOpen = new GarageDoorOpenCommand(garageDoor);
        GarageDoorDownCommand garageDoorDown = new GarageDoorDownCommand(garageDoor);
        /*创建音响的开与关指令*/
        StereoOnWithCDCommand stereoOpen = new StereoOnWithCDCommand(stereo);
        StereoOffCommand stereoOff = new StereoOffCommand(stereo);
        /**现在已经有了全部的命令，接下来将命令安装到遥控器的插槽中*/
        RemoteControl remoteControl = new RemoteControl();//声明一个遥控器对象
        remoteControl.setCommand(0, livingRoomLightOn, livingRoomLightOff);
        remoteControl.setCommand(1, kitchenLightOn, kitchenLightOff);
        remoteControl.setCommand(2, ceilingFanOn, ceilingFanOff);
        remoteControl.setCommand(3, garageDoorOpen, garageDoorDown);
        remoteControl.setCommand(4, stereoOpen, stereoOff);
        System.out.println(remoteControl.toString());

        /*一切准备就绪接下来开始逐个点击遥控器按钮*/
        remoteControl.onButtonWasPushed(0);
        remoteControl.offButtonWasPushed(0);
        remoteControl.onButtonWasPushed(1);
        remoteControl.offButtonWasPushed(1);
        remoteControl.onButtonWasPushed(2);
        remoteControl.offButtonWasPushed(2);
        remoteControl.onButtonWasPushed(3);
        remoteControl.offButtonWasPushed(3);
        remoteControl.onButtonWasPushed(4);
        remoteControl.offButtonWasPushed(4);
    }
}
